import {
    USERNAME
} from '../constants';

import {mySession} from "../../utils";

// 定义一个状态
let initialState = {
    username: ""
};

if(mySession.get("username")){
    initialState.username = mySession.get("username");
}

function userInfo(state = initialState, action) {
    switch (action.type) {
        case USERNAME:
            mySession.set("username",action.username);
            return {...state, username: action.username};
        default:
            return state;
    }
}

export default userInfo;